{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "stunning-detection",
   "metadata": {},
   "outputs": [],
   "source": [
    "from itertools import combinations"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "surgical-collaboration",
   "metadata": {},
   "outputs": [],
   "source": [
    "points = [[0,0],[0,1],[1,0],[0,2],[2,0]]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "daily-structure",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[([0, 0], [0, 1], [1, 0]),\n",
       " ([0, 0], [0, 1], [0, 2]),\n",
       " ([0, 0], [0, 1], [2, 0]),\n",
       " ([0, 0], [1, 0], [0, 2]),\n",
       " ([0, 0], [1, 0], [2, 0]),\n",
       " ([0, 0], [0, 2], [2, 0]),\n",
       " ([0, 1], [1, 0], [0, 2]),\n",
       " ([0, 1], [1, 0], [2, 0]),\n",
       " ([0, 1], [0, 2], [2, 0]),\n",
       " ([1, 0], [0, 2], [2, 0])]"
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "list(combinations(points, 3))"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "educated-prague",
   "metadata": {},
   "source": [
    "https://leetcode.com/problems/largest-triangle-area\n",
    "\n",
    "\n",
    "Runtime: 152 ms, faster than 48.44% of Python3 online submissions for Largest Triangle Area.\n",
    "Memory Usage: 14.4 MB, less than 28.00% of Python3 online submissions for Largest Triangle Area.\n",
    "\n",
    "\n",
    "\n",
    "```python\n",
    "from itertools import combinations\n",
    "\n",
    "def triangle_area(tri):\n",
    "    x1, y1, x2, y2, x3, y3 = tri[0][0], tri[0][1], tri[1][0], tri[1][1], tri[2][0], tri[2][1]\n",
    "    return abs(0.5 * (((x2-x1)*(y3-y1))-((x3-x1)*(y2-y1))))\n",
    "\n",
    "class Solution:\n",
    "    def largestTriangleArea(self, points: List[List[int]]) -> float:\n",
    "        #8:02\n",
    "        largest = 0\n",
    "        for triangle in combinations(points, 3):\n",
    "            area = triangle_area(triangle)\n",
    "            if area > largest:\n",
    "                largest = area\n",
    "        return largest\n",
    "        #8:07\n",
    "```"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "joined-buffalo",
   "metadata": {},
   "outputs": [],
   "source": [
    "    "
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.5"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
